package com.ghca.myinfo.spider.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.handler.CompositePageProcessor;
import us.codecraft.webmagic.pipeline.Pipeline;
import us.codecraft.webmagic.scheduler.Scheduler;

import javax.annotation.Resource;
import java.util.Date;

/**
 * Created by Administrator on 2017/2/6.
 */
@Component
public class SpiderJob {

    @Autowired
    private CompositePageProcessor compositePageProcessor;


    @Autowired
    private Pipeline pipeline;

    @Autowired
    private Scheduler scheduler;

    @Scheduled(fixedRate = 1000*60*2)
    public void start() {
        Spider.create(compositePageProcessor)
                .addPipeline(pipeline)
                .setScheduler(scheduler)
                .addUrl("https://www.sczbbx.com/GCJS/bxgg.aspx").start();
    }

}
